<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:l="clr-namespace:UIControls">
    
    <SolidColorBrush x:Key="SearchTextBox_Background" Color="White" />
    <SolidColorBrush x:Key="SearchTextBox_Foreground" Color="Black" />
    <LinearGradientBrush x:Key="SearchTextBox_Border" StartPoint="0,0" EndPoint="0,1">
        <GradientStop Color="#FFABADB3" Offset="0.05" />
        <GradientStop Color="#FFE2E3EA" Offset="0.07" />
        <GradientStop Color="#FFE3E9EF" Offset="1" />
    </LinearGradientBrush>
    <SolidColorBrush x:Key="SearchTextBox_SearchIconBorder" Color="White" />
    <SolidColorBrush x:Key="SearchTextBox_SearchIconBackground" Color="White" />
    <SolidColorBrush x:Key="LabelTextColor" Color="Silver" />
        
    <Style x:Key="{x:Type l:SearchTextBox}" TargetType="{x:Type l:SearchTextBox}">
        <Setter Property="Background" Value="{StaticResource SearchTextBox_Background}" />
        <Setter Property="BorderBrush" Value="{StaticResource SearchTextBox_Border}" />
        <Setter Property="Foreground" Value="{StaticResource SearchTextBox_Foreground}" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="PlaceholderText"  Value="Search" />
        <Setter Property="HasText" Value="False" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type l:SearchTextBox}">
                    <Border x:Name="Border"
                            Padding="2"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        
                        <Grid x:Name="LayoutGrid">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=ActualHeight}" />
                            </Grid.ColumnDefinitions>
                            <ScrollViewer x:Name="PART_ContentHost" Grid.Column="0" />
                            <Label x:Name="LabelText"
                   Grid.Column="0"
                   Foreground="{StaticResource LabelTextColor}"
                   Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=PlaceholderText}"
                   Padding="2,0,0,0"
                   FontStyle="Italic" />
                            <Border x:Name="PART_SearchIconBorder"
                      Grid.Column="1"
                      BorderThickness="1"
                      Padding="1"
                      VerticalAlignment="Stretch"
                      HorizontalAlignment="Stretch"
                      BorderBrush="{StaticResource SearchTextBox_SearchIconBorder}"
                      Background="{StaticResource SearchTextBox_SearchIconBackground}">
                       <Image x:Name="SearchIcon"
                               Stretch="None"
                               Width="15"
                               Height="15"
                               HorizontalAlignment="Center"
                               VerticalAlignment="Center"
                               Source="pack://application:,,,/UIControls;component/Images/search.png" />
                            </Border>
                        </Grid>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsFocused" Value="True">
                            <Setter Property="Visibility" TargetName="LabelText" Value="Hidden" />
                        </Trigger>
                        <Trigger Property="HasText" Value="True">
                            <Setter Property="Visibility" TargetName="LabelText" Value="Hidden" />
                        </Trigger>

                        
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
            
        </Setter>

    </Style>

</ResourceDictionary>
